# -*- coding: utf-8 -*-
# @Time    : 2020/10/22 15:14
# @Author  : Leo
# @FileName: time_utils.py
# @Software: PyCharm

import datetime
import time


# 7天的时间戳
timeStamp_7days = 24 * 60 * 60 * 7


def dateTime_to_timeStamp(dateTime):
    '''
    字符串的日期格式转为时间戳
    @param dateTime:
    @return:
    example: '2019-06-03 21:19:03' -> 1559567943
    '''
    # 转为时间数组
    timeArray = time.strptime(dateTime, "%Y-%m-%d %H:%M:%S")
    # 转为时间戳
    timeStamp = float(time.mktime(timeArray))
    return timeStamp

def compare_orderTime(orderTime):
    '''
    比较最近一次订餐时间是否在7天以内，以便判断是否发送订餐提醒
    @param orderTime: 用户最近一次订餐时间戳
    @return:
    '''
    # 现在的时间戳
    now_time = time.time()

    diff_time = now_time - orderTime

    # 最近一次订餐时间在7天以内
    if diff_time < timeStamp_7days:
        return True
    # 最近一次订餐时间不在7天以内
    return False


def is_right_time_to_order():
    '''
    判断是否在订餐时间范围内
    @return:
    '''
    return True